<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 构造函数
        function Person(name, age) {
            this.name = name;
            this.age = age;
        }

        // var xm = new Person("xm", 19);
        // console.log( xm );

        // var xh = new Person("xh",20);
        // console.log(xh);


        // createPerson 工厂函数
        function $(name, age) {
            return new Person(name, age);
        }

        var xhei = $("小黑", 22);
        var xhua = $("小花", 19);
        console.log(xhei, xhua);
    </script>
</body>

</html>